﻿namespace HuaWei.CBR
{
    using DevExpress.XtraBars;
    using DevExpress.XtraEditors;
    using DevExpress.XtraTab;
    using HuaWei;
    using HuaWei.CommClass;
    using HuaWei.CommComp;
    using HuaWei.Common;
    using HuaWei.Search;
    using HuaWei.Windows.Forms;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmZJJL : Form
    {
        private BarAndDockingController barAndDockingController;
        private BarDockControl barDockControl;
        private BarDockControl barDockControl1;
        private BarDockControl barDockControl2;
        private BarDockControl barDockControl3;
        private BarLargeButtonItem barLargeButtonItem3;
        private BarLargeButtonItem barLargeButtonItem4;
        private BarManager barManager;
        private SimpleButton btnAddQC;
        private BarLargeButtonItem btnBGJL;
        private BarLargeButtonItem btnClose;
        private SimpleButton btnExport;
        private BarLargeButtonItem btnQDJL;
        private IContainer icontainer = null;
        private ImageList imageList;
        private PanelControl panelControl6;
        private PanelControl panelControl8;
        private SimpleButton simpleButton1;
        private SimpleButton simpleButton2;
        private SimpleButton simpleButton4;
        private XtraTabControl xtraTabControl1;
        private XtraTabControl xtraTabControl2;
        private XtraTabPage xtraTabPage1;
        private XtraTabPage xtraTabPage2;
        private XtraTabPage xtraTabPage3;

        public FrmZJJL()
        {
            this.InitializeComponent();
        }

        private void btnAddQC_Click(object sender, EventArgs e)
        {
            this.method();
        }

        private void btnClose_ItemClick(object sender, ItemClickEventArgs e)
        {
            base.Close();
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            this.method6();
        }

        protected override void DefWndProc(ref Message m)
        {
            if (m.Msg == 0x63)
            {
                Class28.smethod6(this.xtraTabControl1);
            }
            XtraTabPage selectedTabPage = this.xtraTabControl2.SelectedTabPage;
            if (selectedTabPage.Controls.Count > 0)
            {
                Form form = (Form) selectedTabPage.Controls[0];
                Win32API.SendMessage(form.Handle, m.Msg, 0, 0);
            }
            base.DefWndProc(ref m);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer != null))
            {
                this.icontainer.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmZJJL_FormClosing(object sender, FormClosingEventArgs e)
        {
            DevCCHelp.CloseTabControl(this.xtraTabControl2);
        }

        private void FrmZJJL_Load(object sender, EventArgs e)
        {
            Class28.JvBxsoguG(this.xtraTabControl1, true);
            this.xtraTabControl2.SelectedTabPageIndex = 0;
        }

        private void InitializeComponent()
        {
            this.icontainer = new Container();
            ComponentResourceManager resources = new ComponentResourceManager(typeof(FrmZJJL));
            this.barManager = new BarManager(this.icontainer);
            this.barAndDockingController = new BarAndDockingController(this.icontainer);
            this.barDockControl = new BarDockControl();
            this.barDockControl1 = new BarDockControl();
            this.barDockControl2 = new BarDockControl();
            this.barDockControl3 = new BarDockControl();
            this.btnQDJL = new BarLargeButtonItem();
            this.btnBGJL = new BarLargeButtonItem();
            this.barLargeButtonItem3 = new BarLargeButtonItem();
            this.barLargeButtonItem4 = new BarLargeButtonItem();
            this.btnClose = new BarLargeButtonItem();
            this.imageList = new ImageList(this.icontainer);
            this.panelControl6 = new PanelControl();
            this.xtraTabControl1 = new XtraTabControl();
            this.panelControl8 = new PanelControl();
            this.simpleButton2 = new SimpleButton();
            this.btnExport = new SimpleButton();
            this.simpleButton4 = new SimpleButton();
            this.btnAddQC = new SimpleButton();
            this.simpleButton1 = new SimpleButton();
            this.xtraTabControl2 = new XtraTabControl();
            this.xtraTabPage3 = new XtraTabPage();
            this.xtraTabPage1 = new XtraTabPage();
            this.xtraTabPage2 = new XtraTabPage();
            this.barManager.BeginInit();
            this.barAndDockingController.BeginInit();
            this.panelControl6.BeginInit();
            this.panelControl6.SuspendLayout();
            this.xtraTabControl1.BeginInit();
            this.panelControl8.BeginInit();
            this.panelControl8.SuspendLayout();
            this.xtraTabControl2.BeginInit();
            this.xtraTabControl2.SuspendLayout();
            base.SuspendLayout();
            this.barManager.Controller = this.barAndDockingController;
            this.barManager.DockControls.Add(this.barDockControl);
            this.barManager.DockControls.Add(this.barDockControl1);
            this.barManager.DockControls.Add(this.barDockControl2);
            this.barManager.DockControls.Add(this.barDockControl3);
            this.barManager.Form = this;
            this.barManager.Items.AddRange(new BarItem[] { this.btnQDJL, this.btnBGJL, this.barLargeButtonItem3, this.barLargeButtonItem4, this.btnClose });
            this.barManager.LargeImages = this.imageList;
            this.barManager.MaxItemId = 7;
            this.barAndDockingController.PaintStyleName = "Skin";
            this.barAndDockingController.PropertiesBar.AllowLinkLighting = false;
            this.barDockControl.Dock = DockStyle.Top;
            this.barDockControl.Location = new Point(0, 0);
            this.barDockControl.Size = new Size(0x3d0, 0);
            this.barDockControl1.Dock = DockStyle.Bottom;
            this.barDockControl1.Location = new Point(0, 0x21a);
            this.barDockControl1.Size = new Size(0x3d0, 0);
            this.barDockControl2.Dock = DockStyle.Left;
            this.barDockControl2.Location = new Point(0, 0);
            this.barDockControl2.Size = new Size(0, 0x21a);
            this.barDockControl3.Dock = DockStyle.Right;
            this.barDockControl3.Location = new Point(0x3d0, 0);
            this.barDockControl3.Size = new Size(0, 0x21a);
            this.btnQDJL.Id = 5;
            this.btnQDJL.Name = "btnQDJL";
            this.btnBGJL.Id = 6;
            this.btnBGJL.Name = "btnBGJL";
            this.barLargeButtonItem3.Caption = "预付款计量";
            this.barLargeButtonItem3.Id = 2;
            this.barLargeButtonItem3.LargeImageIndex = 6;
            this.barLargeButtonItem3.Name = "barLargeButtonItem3";
            this.barLargeButtonItem4.Caption = "其它计量";
            this.barLargeButtonItem4.Id = 3;
            this.barLargeButtonItem4.LargeImageIndex = 2;
            this.barLargeButtonItem4.Name = "barLargeButtonItem4";
            this.btnClose.Caption = "关闭";
            this.btnClose.Id = 4;
            this.btnClose.LargeImageIndex = 0x15;
            this.btnClose.Name = "btnClose";
            this.btnClose.ItemClick += new ItemClickEventHandler(this.btnClose_ItemClick);
            this.imageList.ImageStream = (ImageListStreamer) resources.GetObject("imageList2.ImageStream");
            this.imageList.TransparentColor = Color.Magenta;
            //this.imageList.Images.SetKeyName(0, "");
            //this.imageList.Images.SetKeyName(1, "");
            //this.imageList.Images.SetKeyName(2, "");
            //this.imageList.Images.SetKeyName(3, "");
            //this.imageList.Images.SetKeyName(4, "");
            //this.imageList.Images.SetKeyName(5, "");
            //this.imageList.Images.SetKeyName(6, "");
            //this.imageList.Images.SetKeyName(7, "");
            //this.imageList.Images.SetKeyName(8, "");
            //this.imageList.Images.SetKeyName(9, "100-JT-001.png");
            //this.imageList.Images.SetKeyName(10, "100-JT-003.png");
            //this.imageList.Images.SetKeyName(11, "300-GJ-002.png");
            //this.imageList.Images.SetKeyName(12, "300-GJ-003.png");
            //this.imageList.Images.SetKeyName(13, "300-ST-001.png");
            //this.imageList.Images.SetKeyName(14, "800-DC-002.png");
            //this.imageList.Images.SetKeyName(15, "800-DC-003.png");
            //this.imageList.Images.SetKeyName(0x10, "800-DC-004.png");
            //this.imageList.Images.SetKeyName(0x11, "800-DR-002.png");
            //this.imageList.Images.SetKeyName(0x12, "KS-001.png");
            //this.imageList.Images.SetKeyName(0x13, "KS-005.png");
            //this.imageList.Images.SetKeyName(20, "KS-008.png");
            //this.imageList.Images.SetKeyName(0x15, "link.ico");
            this.panelControl6.Controls.Add(this.xtraTabControl1);
            this.panelControl6.Controls.Add(this.panelControl8);
            this.panelControl6.Dock = DockStyle.Top;
            this.panelControl6.Location = new Point(0, 0);
            this.panelControl6.Name = "panelControl6";
            this.panelControl6.Size = new Size(0x3d0, 30);
            this.panelControl6.TabIndex = 0x11;
            this.xtraTabControl1.AllowDrop = true;
            this.xtraTabControl1.Dock = DockStyle.Top;
            this.xtraTabControl1.Location = new Point(2, 2);
            this.xtraTabControl1.Name = "xtraTabControl1";
            this.xtraTabControl1.Size = new Size(0x299, 0x1c);
            this.xtraTabControl1.TabIndex = 12;
            this.xtraTabControl1.SelectedPageChanged += new TabPageChangedEventHandler(this.xtraTabControl1_SelectedPageChanged);
            this.xtraTabControl1.SelectedPageChanging += new TabPageChangingEventHandler(this.xtraTabControl1_SelectedPageChanging);
            this.panelControl8.Controls.Add(this.simpleButton2);
            this.panelControl8.Controls.Add(this.btnExport);
            this.panelControl8.Controls.Add(this.simpleButton4);
            this.panelControl8.Controls.Add(this.btnAddQC);
            this.panelControl8.Controls.Add(this.simpleButton1);
            this.panelControl8.Dock = DockStyle.Right;
            this.panelControl8.Location = new Point(0x29b, 2);
            this.panelControl8.Name = "panelControl8";
            this.panelControl8.Size = new Size(0x133, 0x1a);
            this.panelControl8.TabIndex = 13;
            this.simpleButton2.Dock = DockStyle.Right;
            this.simpleButton2.Location = new Point(2, 2);
            this.simpleButton2.Name = "simpleButton2";
            this.simpleButton2.Size = new Size(0x3e, 0x16);
            this.simpleButton2.TabIndex = 10;
            this.simpleButton2.Tag = "-1";
            this.simpleButton2.Text = "计量汇总";
            this.simpleButton2.Click += new EventHandler(this.simpleButton2_Click);
            this.btnExport.Dock = DockStyle.Right;
            this.btnExport.Location = new Point(0x40, 2);
            this.btnExport.Name = "btnExport";
            this.btnExport.Size = new Size(0x3e, 0x16);
            this.btnExport.TabIndex = 8;
            this.btnExport.Tag = "-1";
            this.btnExport.Text = "数据导出";
            this.btnExport.Click += new EventHandler(this.btnExport_Click);
            this.simpleButton4.Dock = DockStyle.Right;
            this.simpleButton4.Location = new Point(0x7e, 2);
            this.simpleButton4.Name = "simpleButton4";
            this.simpleButton4.Size = new Size(0x37, 0x16);
            this.simpleButton4.TabIndex = 12;
            this.simpleButton4.Tag = "-1";
            this.simpleButton4.Text = "数据撤回";
            this.simpleButton4.Click += new EventHandler(this.simpleButton4_Click);
            this.btnAddQC.Dock = DockStyle.Right;
            this.btnAddQC.Location = new Point(0xb5, 2);
            this.btnAddQC.Name = "btnAddQC";
            this.btnAddQC.Size = new Size(0x3e, 0x16);
            this.btnAddQC.TabIndex = 7;
            this.btnAddQC.Tag = "-1";
            this.btnAddQC.Text = "新增期次";
            this.btnAddQC.Click += new EventHandler(this.btnAddQC_Click);
            this.simpleButton1.Dock = DockStyle.Right;
            this.simpleButton1.Location = new Point(0xf3, 2);
            this.simpleButton1.Name = "simpleButton1";
            this.simpleButton1.Size = new Size(0x3e, 0x16);
            this.simpleButton1.TabIndex = 9;
            this.simpleButton1.Tag = "-1";
            this.simpleButton1.Text = "修改期次";
            this.simpleButton1.Click += new EventHandler(this.simpleButton1_Click);
            this.xtraTabControl2.Dock = DockStyle.Fill;
            this.xtraTabControl2.Location = new Point(0, 30);
            this.xtraTabControl2.Name = "xtraTabControl2";
            this.xtraTabControl2.SelectedTabPage = this.xtraTabPage3;
            this.xtraTabControl2.Size = new Size(0x3d0, 0x1fc);
            this.xtraTabControl2.TabIndex = 0x16;
            this.xtraTabControl2.TabPages.AddRange(new XtraTabPage[] { this.xtraTabPage1, this.xtraTabPage2, this.xtraTabPage3 });
            this.xtraTabControl2.SelectedPageChanged += new TabPageChangedEventHandler(this.xtraTabControl2_SelectedPageChanged);
            this.xtraTabControl2.SelectedPageChanging += new TabPageChangingEventHandler(this.xtraTabControl2_SelectedPageChanging);
            this.xtraTabPage3.Name = "xtraTabPage3";
            this.xtraTabPage3.Size = new Size(0x3c9, 0x1de);
            this.xtraTabPage3.Text = "其它计量";
            this.xtraTabPage1.Name = "xtraTabPage1";
            this.xtraTabPage1.Size = new Size(0x3c9, 0x1de);
            this.xtraTabPage1.Text = "中间计量";
            this.xtraTabPage2.Name = "xtraTabPage2";
            this.xtraTabPage2.Size = new Size(0x3c9, 0x1de);
            this.xtraTabPage2.Text = "变更计量";
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x3d0, 0x21a);
            base.Controls.Add(this.xtraTabControl2);
            base.Controls.Add(this.panelControl6);
            base.Controls.Add(this.barDockControl2);
            base.Controls.Add(this.barDockControl3);
            base.Controls.Add(this.barDockControl1);
            base.Controls.Add(this.barDockControl);
            base.Name = "FrmZJJL";
            base.ShowInTaskbar = false;
            this.Text = "中间计量";
            base.FormClosing += new FormClosingEventHandler(this.FrmZJJL_FormClosing);
            base.Load += new EventHandler(this.FrmZJJL_Load);
            this.barManager.EndInit();
            this.barAndDockingController.EndInit();
            this.panelControl6.EndInit();
            this.panelControl6.ResumeLayout(false);
            this.xtraTabControl1.EndInit();
            this.panelControl8.EndInit();
            this.panelControl8.ResumeLayout(false);
            this.xtraTabControl2.EndInit();
            this.xtraTabControl2.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private bool method()
        {
            FrmAddQc qc = new FrmAddQc();
            qc.IniQC(true);
            if (qc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Class28.AddTabPage(this.xtraTabControl1, GParams.QCInfo);
                return true;
            }
            return false;
        }

        private void method1()
        {
            XtraTabPage selectedTabPage = this.xtraTabControl2.SelectedTabPage;
            if (selectedTabPage.Controls.Count == 0)
            {
                switch (this.xtraTabControl2.SelectedTabPageIndex)
                {
                    case 0:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmQDJL frm = new FrmQDJL();
                            CHelp.ControlAddForm(selectedTabPage, frm, true);
                        }
                        break;

                    case 1:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmBGJL mbgjl = new FrmBGJL();
                            CHelp.ControlAddForm(selectedTabPage, mbgjl, true);
                        }
                        break;

                    case 2:
                        if (!selectedTabPage.HasChildren)
                        {
                            FrmQTJL mqtjl = new FrmQTJL();
                            CHelp.ControlAddForm(selectedTabPage, mqtjl, true);
                        }
                        break;
                }
            }
            else
            {
                this.method2(0x62);
            }
        }

        private void method2(int numD)
        {
            Win32API.SendMessage(base.Handle, numD, 0, 0);
        }

        private void method3(object sender, EventArgs e)
        {
            int num = 0;
            QCInfo tag = (QCInfo) this.xtraTabControl1.SelectedTabPage.Tag;
            if (this.xtraTabControl1.SelectedTabPageIndex > 1)
            {
                num = this.xtraTabControl1.SelectedTabPageIndex - 1;
                QCInfo info2 = (QCInfo) this.xtraTabControl1.TabPages[num].Tag;
                if (info2.QCZT.Equals(0))
                {
                    MsgBox.ShowMsg("本期之前存在末结束的期次！");
                    return;
                }
            }
            tag.QCZT = 1;
            this.xtraTabControl1.SelectedTabPage.Tag = tag;
            DBHelp.ExeSql("update xmqc set zt=1 where bdid='#bdid#' and qcid='#qcid#'".Replace("#bdid#", GParams._BDID).Replace("#qcid#", tag.QCID));
            DBHelp.ExeSql("update QDJL_M set spzt=1 where bdid='#bdid#' and qcid='#qcid#'".Replace("#bdid#", GParams._BDID).Replace("#qcid#", tag.QCID));
            DBHelp.ExeSql("update BGQDJL_M set spzt=1 where bdid='#bdid#' and qcid='#qcid#'".Replace("#bdid#", GParams._BDID).Replace("#qcid#", tag.QCID));
            this.xtraTabControl1.SelectedTabPage.Tag = tag;
            GParams.QCInfo = tag;
            this.method2(0x63);
        }

        private void method4(object sender, EventArgs e)
        {
            int num = 0;
            if (this.xtraTabControl1.SelectedTabPageIndex < (this.xtraTabControl1.TabPages.Count - 1))
            {
                num = this.xtraTabControl1.SelectedTabPageIndex + 1;
                QCInfo info = (QCInfo) this.xtraTabControl1.TabPages[num].Tag;
                if (info.QCZT.Equals(1))
                {
                    MsgBox.ShowMsg("本期之后存在已结束的期次！");
                    return;
                }
            }
            QCInfo tag = (QCInfo) this.xtraTabControl1.SelectedTabPage.Tag;
            tag.QCZT = 0;
            this.xtraTabControl1.SelectedTabPage.Tag = tag;
            DBHelp.ExeSql("update xmqc set zt=0 where bdid='#bdid#' and qcid='#qcid#'".Replace("#bdid#", GParams._BDID).Replace("#qcid#", tag.QCID));
            this.xtraTabControl1.SelectedTabPage.Tag = tag;
            GParams.QCInfo = tag;
            this.method2(0x63);
        }

        private bool method5()
        {
            if (GParams.QCInfo.QCZT.Equals(-1))
            {
                FrmAddQc qc = new FrmAddQc();
                qc.IniQC(false);
                if (qc.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    this.xtraTabControl1.SelectedTabPage.Tag = GParams.QCInfo;
                    Class28.SetTabPageToolTip(this.xtraTabControl1.SelectedTabPage);
                    return true;
                }
            }
            else
            {
                MsgBox.ShowMsg("当前数据已被锁定！");
            }
            return false;
        }

        private void method6()
        {
            this.method2(0x61);
            if (Class28.ValidateQCInfo(this.xtraTabControl1, EOPLX.UPLOAD) && Class37.smethod1().CBRExpJLData())
            {
                Class28.smethod4(DBHelp.IniIDA(), this.xtraTabControl1, 0);
                this.method2(0x63);
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.method5();
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.method2(0x61);
            new FrmSearchJLHZ().ShowDialog();
        }

        private void simpleButton4_Click(object sender, EventArgs e)
        {
            this.method2(0x61);
            if (Class28.ValidateQCInfo(this.xtraTabControl1, EOPLX.CANCEL) && Class38.smethod1("CancelUpdate", null, GParams.LoginId, GParams._BDID, GParams.QCInfo.QCID, ""))
            {
                Class28.smethod4(DBHelp.IniIDA(), this.xtraTabControl1, -1);
                this.method2(0x63);
                this.method2(0x64);
            }
        }

        private void xtraTabControl1_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            if (e.Page.Tag != null)
            {
                GParams.QCInfo = (QCInfo) e.Page.Tag;
                this.method2(0x62);
            }
        }

        private void xtraTabControl1_SelectedPageChanging(object sender, TabPageChangingEventArgs e)
        {
            this.method2(0x61);
        }

        private void xtraTabControl2_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            this.method1();
        }

        private void xtraTabControl2_SelectedPageChanging(object sender, TabPageChangingEventArgs e)
        {
            this.method2(0x61);
        }
    }
}

